<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #imgContainer {
      background-color: #ccc;
      width: 500px;
      height: 500px;
    }
  </style>
</head>

<body>
  <div id="imgContainer"></div>
  <script>
    var imgContainer;
    window.onload = function () {
      imgContainer = document.getElementById('imgContainer');
      imgContainer.ondragover = function (e) {
        e.preventDefault();
      }
      imgContainer.ondrop = function (e) {
        e.preventDefault();
        var f = e.dataTransfer.files[0];
        var fileReader = new FileReader();
        fileReader.onload = function (e) {
          imgContainer.innerHTML = `<img src="${fileReader.result}">`;
        }
        fileReader.readAsDataURL(f)
      }
    }
  </script>
</body>

</html>